package com.itany.corejava.code07_常用类.泛型;

/**
 * @author MissChen
 * @date 2024年03月02日 14:52
 */
public class Person implements  CompareInterface<Person>{
    private String name;
    private int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    /**
     * 实现比较规则，此时通过年龄进行比较
     * @param person
     * @return
     */
    @Override
    public int compareTo(Person person) {
        if(this.getAge()>person.getAge()){
            return 1;
        }else if(this.getAge()<person.getAge()){
            return -1;
        }
        return 0;
    }
}
